package com.example.zx_springboot.config;



import com.example.zx_springboot.interceptors.JWTInterceptor;
import com.example.zx_springboot.jwt.JWTUtils;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class JwtConfig implements WebMvcConfigurer {

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        //添加不拦截的方法（登入，注册）
        String[] patterns = new String[] {"/user/login","/*.html","/user/register","/person","/file/*"};
        registry.addInterceptor(new JWTInterceptor())
                .addPathPatterns("/**")         //其他接口token验证
                .excludePathPatterns(patterns);  //不进行token验证
    }
}
